<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>十进制转二进制</title>
</head>
<body>
<script type="application/javascript">
    function tenForTwo (twoCode, res) {
      res = twoCode % 2 + res
      twoCode = Math.floor(twoCode / 2)
      if (twoCode === 1) return '1' + res
      else return tenForTwo(twoCode, res)
    }
    console.log(tenForTwo(20000, ''))
</script>
</body>
</html>
